package com.ldy;

import org.json.JSONObject;
import org.junit.Test;

import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 描述：<br>
 * 版权：Copyright (c) 2011 ~ 2017<br>
 * 公司：北京活力天汇<br>
 * 作者：刘德咏<br>
 * 版本：1.0<br>
 * 创建日期：2017/9/24<br>
 */
public class AccessFeildTest {
    @Test
    public void test1() {
        Calendar c = Calendar.getInstance();
        System.out.println(c.hashCode());

        JSONObject a1 = new JSONObject();
        JSONObject a2 = new JSONObject();
        JSONObject a3 = new JSONObject();
        a1.put("date", "2018");
        a1.put("id", "1");
        a2.put("date", "2018");
        a2.put("id", "3");
        a3.put("date", "2019");
        a3.put("id", "2");
        List<JSONObject> aa = new ArrayList<>();
        Set<String> set = new HashSet<>();
        set.add("2018");
        set.add("2019");
//        aa.stream().map(new Function<JSONObject, Object>() {
//            @Override
//            public Object apply(JSONObject jsonObject) {
//                Map<String, List<JSONObject>> result = new HashMap<>();
//                String dateKey = jsonObject.getString("date");
//                if (result.containsKey(dateKey)) {
//                    result.get(dateKey).add(jsonObject);
//                } else {
//                    List<JSONObject> item = new ArrayList<>();
//                    item.add(jsonObject);
//                    result.put(dateKey, item);
//                }
//                return result;
//            }
//        });
//        aa.stream().collect(Collectors.groupingBy(JSONObject::getString))
        System.out.println(System.currentTimeMillis());
    }

    @Test
    public void  test2() throws Exception {
        Map<String, Object> map = new HashMap<>();
        map.put("aa", 22);
        map.putIfAbsent("aa", 222);
        System.out.println(map.get("aa"));
    }
}
